package com.alibaba.polardbx.optimizer.core.datatype;

import com.alibaba.polardbx.optimizer.core.TddlRelDataTypeSystemImpl;
import com.alibaba.polardbx.optimizer.core.TddlTypeFactoryImpl;
import org.apache.calcite.rel.type.RelDataType;
import org.apache.calcite.rel.type.RelDataTypeFactory;
import org.apache.calcite.sql.type.SqlTypeName;
import org.junit.Assert;
import org.junit.Test;

public class TypeWithCollationTest {
    private final static RelDataTypeFactory FACTORY = new TddlTypeFactoryImpl(TddlRelDataTypeSystemImpl.getInstance());

    @Test
    public void testMySQL57() {
        doTestCollation("big5", "big5_chinese_ci");
        doTestCollation("big5", "big5_bin");
        doTestCollation("dec8", "dec8_swedish_ci");
        doTestCollation("dec8", "dec8_bin");
        doTestCollation("cp850", "cp850_general_ci");
        doTestCollation("cp850", "cp850_bin");
        doTestCollation("hp8", "hp8_english_ci");
        doTestCollation("hp8", "hp8_bin");
        doTestCollation("koi8r", "koi8r_general_ci");
        doTestCollation("koi8r", "koi8r_bin");
        doTestCollation("latin1", "latin1_german1_ci");
        doTestCollation("latin1", "latin1_swedish_ci");
        doTestCollation("latin1", "latin1_danish_ci");
        doTestCollation("latin1", "latin1_german2_ci");
        doTestCollation("latin1", "latin1_bin");
        doTestCollation("latin1", "latin1_general_ci");
        doTestCollation("latin1", "latin1_general_cs");
        doTestCollation("latin1", "latin1_spanish_ci");
        doTestCollation("latin2", "latin2_czech_cs");
        doTestCollation("latin2", "latin2_general_ci");
        doTestCollation("latin2", "latin2_hungarian_ci");
        doTestCollation("latin2", "latin2_croatian_ci");
        doTestCollation("latin2", "latin2_bin");
        doTestCollation("swe7", "swe7_swedish_ci");
        doTestCollation("swe7", "swe7_bin");
        doTestCollation("ascii", "ascii_general_ci");
        doTestCollation("ascii", "ascii_bin");
        doTestCollation("ujis", "ujis_japanese_ci");
        doTestCollation("ujis", "ujis_bin");
        doTestCollation("sjis", "sjis_japanese_ci");
        doTestCollation("sjis", "sjis_bin");
        doTestCollation("hebrew", "hebrew_general_ci");
        doTestCollation("hebrew", "hebrew_bin");
        doTestCollation("tis620", "tis620_thai_ci");
        doTestCollation("tis620", "tis620_bin");
        doTestCollation("euckr", "euckr_korean_ci");
        doTestCollation("euckr", "euckr_bin");
        doTestCollation("koi8u", "koi8u_general_ci");
        doTestCollation("koi8u", "koi8u_bin");
        doTestCollation("gb2312", "gb2312_chinese_ci");
        doTestCollation("gb2312", "gb2312_bin");
        doTestCollation("greek", "greek_general_ci");
        doTestCollation("greek", "greek_bin");
        doTestCollation("cp1250", "cp1250_general_ci");
        doTestCollation("cp1250", "cp1250_czech_cs");
        doTestCollation("cp1250", "cp1250_croatian_ci");
        doTestCollation("cp1250", "cp1250_bin");
        doTestCollation("cp1250", "cp1250_polish_ci");
        doTestCollation("gbk", "gbk_chinese_ci");
        doTestCollation("gbk", "gbk_bin");
        doTestCollation("latin5", "latin5_turkish_ci");
        doTestCollation("latin5", "latin5_bin");
        doTestCollation("armscii8", "armscii8_general_ci");
        doTestCollation("armscii8", "armscii8_bin");
        doTestCollation("utf8", "utf8_general_ci");
        doTestCollation("utf8", "utf8_bin");
        doTestCollation("utf8", "utf8_unicode_ci");
        doTestCollation("utf8", "utf8_icelandic_ci");
        doTestCollation("utf8", "utf8_latvian_ci");
        doTestCollation("utf8", "utf8_romanian_ci");
        doTestCollation("utf8", "utf8_slovenian_ci");
        doTestCollation("utf8", "utf8_polish_ci");
        doTestCollation("utf8", "utf8_estonian_ci");
        doTestCollation("utf8", "utf8_spanish_ci");
        doTestCollation("utf8", "utf8_swedish_ci");
        doTestCollation("utf8", "utf8_turkish_ci");
        doTestCollation("utf8", "utf8_czech_ci");
        doTestCollation("utf8", "utf8_danish_ci");
        doTestCollation("utf8", "utf8_lithuanian_ci");
        doTestCollation("utf8", "utf8_slovak_ci");
        doTestCollation("utf8", "utf8_spanish2_ci");
        doTestCollation("utf8", "utf8_roman_ci");
        doTestCollation("utf8", "utf8_persian_ci");
        doTestCollation("utf8", "utf8_esperanto_ci");
        doTestCollation("utf8", "utf8_hungarian_ci");
        doTestCollation("utf8", "utf8_sinhala_ci");
        doTestCollation("utf8", "utf8_german2_ci");
        doTestCollation("utf8", "utf8_croatian_ci");
        doTestCollation("utf8", "utf8_unicode_520_ci");
        doTestCollation("utf8", "utf8_vietnamese_ci");
        doTestCollation("utf8", "utf8_general_mysql500_ci");
        doTestCollation("ucs2", "ucs2_general_ci");
        doTestCollation("ucs2", "ucs2_bin");
        doTestCollation("ucs2", "ucs2_unicode_ci");
        doTestCollation("ucs2", "ucs2_icelandic_ci");
        doTestCollation("ucs2", "ucs2_latvian_ci");
        doTestCollation("ucs2", "ucs2_romanian_ci");
        doTestCollation("ucs2", "ucs2_slovenian_ci");
        doTestCollation("ucs2", "ucs2_polish_ci");
        doTestCollation("ucs2", "ucs2_estonian_ci");
        doTestCollation("ucs2", "ucs2_spanish_ci");
        doTestCollation("ucs2", "ucs2_swedish_ci");
        doTestCollation("ucs2", "ucs2_turkish_ci");
        doTestCollation("ucs2", "ucs2_czech_ci");
        doTestCollation("ucs2", "ucs2_danish_ci");
        doTestCollation("ucs2", "ucs2_lithuanian_ci");
        doTestCollation("ucs2", "ucs2_slovak_ci");
        doTestCollation("ucs2", "ucs2_spanish2_ci");
        doTestCollation("ucs2", "ucs2_roman_ci");
        doTestCollation("ucs2", "ucs2_persian_ci");
        doTestCollation("ucs2", "ucs2_esperanto_ci");
        doTestCollation("ucs2", "ucs2_hungarian_ci");
        doTestCollation("ucs2", "ucs2_sinhala_ci");
        doTestCollation("ucs2", "ucs2_german2_ci");
        doTestCollation("ucs2", "ucs2_croatian_ci");
        doTestCollation("ucs2", "ucs2_unicode_520_ci");
        doTestCollation("ucs2", "ucs2_vietnamese_ci");
        doTestCollation("ucs2", "ucs2_general_mysql500_ci");
        doTestCollation("cp866", "cp866_general_ci");
        doTestCollation("cp866", "cp866_bin");
        doTestCollation("keybcs2", "keybcs2_general_ci");
        doTestCollation("keybcs2", "keybcs2_bin");
        doTestCollation("macce", "macce_general_ci");
        doTestCollation("macce", "macce_bin");
        doTestCollation("macroman", "macroman_general_ci");
        doTestCollation("macroman", "macroman_bin");
        doTestCollation("cp852", "cp852_general_ci");
        doTestCollation("cp852", "cp852_bin");
        doTestCollation("latin7", "latin7_estonian_cs");
        doTestCollation("latin7", "latin7_general_ci");
        doTestCollation("latin7", "latin7_general_cs");
        doTestCollation("latin7", "latin7_bin");
        doTestCollation("utf8mb4", "utf8mb4_general_ci");
        doTestCollation("utf8mb4", "utf8mb4_bin");
        doTestCollation("utf8mb4", "utf8mb4_unicode_ci");
        doTestCollation("utf8mb4", "utf8mb4_icelandic_ci");
        doTestCollation("utf8mb4", "utf8mb4_latvian_ci");
        doTestCollation("utf8mb4", "utf8mb4_romanian_ci");
        doTestCollation("utf8mb4", "utf8mb4_slovenian_ci");
        doTestCollation("utf8mb4", "utf8mb4_polish_ci");
        doTestCollation("utf8mb4", "utf8mb4_estonian_ci");
        doTestCollation("utf8mb4", "utf8mb4_spanish_ci");
        doTestCollation("utf8mb4", "utf8mb4_swedish_ci");
        doTestCollation("utf8mb4", "utf8mb4_turkish_ci");
        doTestCollation("utf8mb4", "utf8mb4_czech_ci");
        doTestCollation("utf8mb4", "utf8mb4_danish_ci");
        doTestCollation("utf8mb4", "utf8mb4_lithuanian_ci");
        doTestCollation("utf8mb4", "utf8mb4_slovak_ci");
        doTestCollation("utf8mb4", "utf8mb4_spanish2_ci");
        doTestCollation("utf8mb4", "utf8mb4_roman_ci");
        doTestCollation("utf8mb4", "utf8mb4_persian_ci");
        doTestCollation("utf8mb4", "utf8mb4_esperanto_ci");
        doTestCollation("utf8mb4", "utf8mb4_hungarian_ci");
        doTestCollation("utf8mb4", "utf8mb4_sinhala_ci");
        doTestCollation("utf8mb4", "utf8mb4_german2_ci");
        doTestCollation("utf8mb4", "utf8mb4_croatian_ci");
        doTestCollation("utf8mb4", "utf8mb4_unicode_520_ci");
        doTestCollation("utf8mb4", "utf8mb4_vietnamese_ci");
        doTestCollation("cp1251", "cp1251_bulgarian_ci");
        doTestCollation("cp1251", "cp1251_ukrainian_ci");
        doTestCollation("cp1251", "cp1251_bin");
        doTestCollation("cp1251", "cp1251_general_ci");
        doTestCollation("cp1251", "cp1251_general_cs");
        doTestCollation("utf16", "utf16_general_ci");
        doTestCollation("utf16", "utf16_bin");
        doTestCollation("utf16", "utf16_unicode_ci");
        doTestCollation("utf16", "utf16_icelandic_ci");
        doTestCollation("utf16", "utf16_latvian_ci");
        doTestCollation("utf16", "utf16_romanian_ci");
        doTestCollation("utf16", "utf16_slovenian_ci");
        doTestCollation("utf16", "utf16_polish_ci");
        doTestCollation("utf16", "utf16_estonian_ci");
        doTestCollation("utf16", "utf16_spanish_ci");
        doTestCollation("utf16", "utf16_swedish_ci");
        doTestCollation("utf16", "utf16_turkish_ci");
        doTestCollation("utf16", "utf16_czech_ci");
        doTestCollation("utf16", "utf16_danish_ci");
        doTestCollation("utf16", "utf16_lithuanian_ci");
        doTestCollation("utf16", "utf16_slovak_ci");
        doTestCollation("utf16", "utf16_spanish2_ci");
        doTestCollation("utf16", "utf16_roman_ci");
        doTestCollation("utf16", "utf16_persian_ci");
        doTestCollation("utf16", "utf16_esperanto_ci");
        doTestCollation("utf16", "utf16_hungarian_ci");
        doTestCollation("utf16", "utf16_sinhala_ci");
        doTestCollation("utf16", "utf16_german2_ci");
        doTestCollation("utf16", "utf16_croatian_ci");
        doTestCollation("utf16", "utf16_unicode_520_ci");
        doTestCollation("utf16", "utf16_vietnamese_ci");
        doTestCollation("utf16le", "utf16le_general_ci");
        doTestCollation("utf16le", "utf16le_bin");
        doTestCollation("cp1256", "cp1256_general_ci");
        doTestCollation("cp1256", "cp1256_bin");
        doTestCollation("cp1257", "cp1257_lithuanian_ci");
        doTestCollation("cp1257", "cp1257_bin");
        doTestCollation("cp1257", "cp1257_general_ci");
        doTestCollation("utf32", "utf32_general_ci");
        doTestCollation("utf32", "utf32_bin");
        doTestCollation("utf32", "utf32_unicode_ci");
        doTestCollation("utf32", "utf32_icelandic_ci");
        doTestCollation("utf32", "utf32_latvian_ci");
        doTestCollation("utf32", "utf32_romanian_ci");
        doTestCollation("utf32", "utf32_slovenian_ci");
        doTestCollation("utf32", "utf32_polish_ci");
        doTestCollation("utf32", "utf32_estonian_ci");
        doTestCollation("utf32", "utf32_spanish_ci");
        doTestCollation("utf32", "utf32_swedish_ci");
        doTestCollation("utf32", "utf32_turkish_ci");
        doTestCollation("utf32", "utf32_czech_ci");
        doTestCollation("utf32", "utf32_danish_ci");
        doTestCollation("utf32", "utf32_lithuanian_ci");
        doTestCollation("utf32", "utf32_slovak_ci");
        doTestCollation("utf32", "utf32_spanish2_ci");
        doTestCollation("utf32", "utf32_roman_ci");
        doTestCollation("utf32", "utf32_persian_ci");
        doTestCollation("utf32", "utf32_esperanto_ci");
        doTestCollation("utf32", "utf32_hungarian_ci");
        doTestCollation("utf32", "utf32_sinhala_ci");
        doTestCollation("utf32", "utf32_german2_ci");
        doTestCollation("utf32", "utf32_croatian_ci");
        doTestCollation("utf32", "utf32_unicode_520_ci");
        doTestCollation("utf32", "utf32_vietnamese_ci");
        doTestCollation("binary", "binary");
        doTestCollation("geostd8", "geostd8_general_ci");
        doTestCollation("geostd8", "geostd8_bin");
        doTestCollation("cp932", "cp932_japanese_ci");
        doTestCollation("cp932", "cp932_bin");
        doTestCollation("eucjpms", "eucjpms_japanese_ci");
        doTestCollation("eucjpms", "eucjpms_bin");
        doTestCollation("gb18030", "gb18030_chinese_ci");
    }

    @Test
    public void testUTF8MB3() {
        doTestCollation("utf8mb3", "utf8_bin");
        doTestCollation("utf8mb3", "utf8_croatian_ci");
        doTestCollation("utf8mb3", "utf8_czech_ci");
        doTestCollation("utf8mb3", "utf8_danish_ci");
        doTestCollation("utf8mb3", "utf8_esperanto_ci");
        doTestCollation("utf8mb3", "utf8_estonian_ci");
        doTestCollation("utf8mb3", "utf8_general_ci");
        doTestCollation("utf8mb3", "utf8_general_mysql500_ci");
        doTestCollation("utf8mb3", "utf8_german2_ci");
        doTestCollation("utf8mb3", "utf8_hungarian_ci");
        doTestCollation("utf8mb3", "utf8_icelandic_ci");
        doTestCollation("utf8mb3", "utf8_latvian_ci");
        doTestCollation("utf8mb3", "utf8_lithuanian_ci");
        doTestCollation("utf8mb3", "utf8_persian_ci");
        doTestCollation("utf8mb3", "utf8_polish_ci");
        doTestCollation("utf8mb3", "utf8_romanian_ci");
        doTestCollation("utf8mb3", "utf8_roman_ci");
        doTestCollation("utf8mb3", "utf8_sinhala_ci");
        doTestCollation("utf8mb3", "utf8_slovak_ci");
        doTestCollation("utf8mb3", "utf8_slovenian_ci");
        doTestCollation("utf8mb3", "utf8_spanish2_ci");
        doTestCollation("utf8mb3", "utf8_spanish_ci");
        doTestCollation("utf8mb3", "utf8_swedish_ci");
        // doTestCollation("utf8mb3", "utf8_tolower_ci");
        doTestCollation("utf8mb3", "utf8_turkish_ci");
        doTestCollation("utf8mb3", "utf8_unicode_520_ci");
        doTestCollation("utf8mb3", "utf8_unicode_ci");
        doTestCollation("utf8mb3", "utf8_vietnamese_ci");
    }

    @Test
    public void testMySQL80() {
        doTestCollation("armscii8", "armscii8_bin");
        doTestCollation("armscii8", "armscii8_general_ci");
        doTestCollation("ascii", "ascii_bin");
        doTestCollation("ascii", "ascii_general_ci");
        doTestCollation("big5", "big5_bin");
        doTestCollation("big5", "big5_chinese_ci");
        doTestCollation("binary", "binary");
        doTestCollation("cp1250", "cp1250_bin");
        doTestCollation("cp1250", "cp1250_croatian_ci");
        doTestCollation("cp1250", "cp1250_czech_cs");
        doTestCollation("cp1250", "cp1250_general_ci");
        doTestCollation("cp1250", "cp1250_polish_ci");
        doTestCollation("cp1251", "cp1251_bin");
        doTestCollation("cp1251", "cp1251_bulgarian_ci");
        doTestCollation("cp1251", "cp1251_general_ci");
        doTestCollation("cp1251", "cp1251_general_cs");
        doTestCollation("cp1251", "cp1251_ukrainian_ci");
        doTestCollation("cp1256", "cp1256_bin");
        doTestCollation("cp1256", "cp1256_general_ci");
        doTestCollation("cp1257", "cp1257_bin");
        doTestCollation("cp1257", "cp1257_general_ci");
        doTestCollation("cp1257", "cp1257_lithuanian_ci");
        doTestCollation("cp850", "cp850_bin");
        doTestCollation("cp850", "cp850_general_ci");
        doTestCollation("cp852", "cp852_bin");
        doTestCollation("cp852", "cp852_general_ci");
        doTestCollation("cp866", "cp866_bin");
        doTestCollation("cp866", "cp866_general_ci");
        doTestCollation("cp932", "cp932_bin");
        doTestCollation("cp932", "cp932_japanese_ci");
        doTestCollation("dec8", "dec8_bin");
        doTestCollation("dec8", "dec8_swedish_ci");
        doTestCollation("eucjpms", "eucjpms_bin");
        doTestCollation("eucjpms", "eucjpms_japanese_ci");
        doTestCollation("euckr", "euckr_bin");
        doTestCollation("euckr", "euckr_korean_ci");
        doTestCollation("gb18030", "gb18030_bin");
        doTestCollation("gb18030", "gb18030_chinese_ci");
        doTestCollation("gb18030", "gb18030_unicode_520_ci");
        doTestCollation("gb2312", "gb2312_bin");
        doTestCollation("gb2312", "gb2312_chinese_ci");
        doTestCollation("gbk", "gbk_bin");
        doTestCollation("gbk", "gbk_chinese_ci");
        doTestCollation("geostd8", "geostd8_bin");
        doTestCollation("geostd8", "geostd8_general_ci");
        doTestCollation("greek", "greek_bin");
        doTestCollation("greek", "greek_general_ci");
        doTestCollation("hebrew", "hebrew_bin");
        doTestCollation("hebrew", "hebrew_general_ci");
        doTestCollation("hp8", "hp8_bin");
        doTestCollation("hp8", "hp8_english_ci");
        doTestCollation("keybcs2", "keybcs2_bin");
        doTestCollation("keybcs2", "keybcs2_general_ci");
        doTestCollation("koi8r", "koi8r_bin");
        doTestCollation("koi8r", "koi8r_general_ci");
        doTestCollation("koi8u", "koi8u_bin");
        doTestCollation("koi8u", "koi8u_general_ci");
        doTestCollation("latin1", "latin1_bin");
        doTestCollation("latin1", "latin1_danish_ci");
        doTestCollation("latin1", "latin1_general_ci");
        doTestCollation("latin1", "latin1_general_cs");
        doTestCollation("latin1", "latin1_german1_ci");
        doTestCollation("latin1", "latin1_german2_ci");
        doTestCollation("latin1", "latin1_spanish_ci");
        doTestCollation("latin1", "latin1_swedish_ci");
        doTestCollation("latin2", "latin2_bin");
        doTestCollation("latin2", "latin2_croatian_ci");
        doTestCollation("latin2", "latin2_czech_cs");
        doTestCollation("latin2", "latin2_general_ci");
        doTestCollation("latin2", "latin2_hungarian_ci");
        doTestCollation("latin5", "latin5_bin");
        doTestCollation("latin5", "latin5_turkish_ci");
        doTestCollation("latin7", "latin7_bin");
        doTestCollation("latin7", "latin7_estonian_cs");
        doTestCollation("latin7", "latin7_general_ci");
        doTestCollation("latin7", "latin7_general_cs");
        doTestCollation("macce", "macce_bin");
        doTestCollation("macce", "macce_general_ci");
        doTestCollation("macroman", "macroman_bin");
        doTestCollation("macroman", "macroman_general_ci");
        doTestCollation("sjis", "sjis_bin");
        doTestCollation("sjis", "sjis_japanese_ci");
        doTestCollation("swe7", "swe7_bin");
        doTestCollation("swe7", "swe7_swedish_ci");
        doTestCollation("tis620", "tis620_bin");
        doTestCollation("tis620", "tis620_thai_ci");
        doTestCollation("ucs2", "ucs2_bin");
        doTestCollation("ucs2", "ucs2_croatian_ci");
        doTestCollation("ucs2", "ucs2_czech_ci");
        doTestCollation("ucs2", "ucs2_danish_ci");
        doTestCollation("ucs2", "ucs2_esperanto_ci");
        doTestCollation("ucs2", "ucs2_estonian_ci");
        doTestCollation("ucs2", "ucs2_general_ci");
        doTestCollation("ucs2", "ucs2_general_mysql500_ci");
        doTestCollation("ucs2", "ucs2_german2_ci");
        doTestCollation("ucs2", "ucs2_hungarian_ci");
        doTestCollation("ucs2", "ucs2_icelandic_ci");
        doTestCollation("ucs2", "ucs2_latvian_ci");
        doTestCollation("ucs2", "ucs2_lithuanian_ci");
        doTestCollation("ucs2", "ucs2_persian_ci");
        doTestCollation("ucs2", "ucs2_polish_ci");
        doTestCollation("ucs2", "ucs2_romanian_ci");
        doTestCollation("ucs2", "ucs2_roman_ci");
        doTestCollation("ucs2", "ucs2_sinhala_ci");
        doTestCollation("ucs2", "ucs2_slovak_ci");
        doTestCollation("ucs2", "ucs2_slovenian_ci");
        doTestCollation("ucs2", "ucs2_spanish2_ci");
        doTestCollation("ucs2", "ucs2_spanish_ci");
        doTestCollation("ucs2", "ucs2_swedish_ci");
        doTestCollation("ucs2", "ucs2_turkish_ci");
        doTestCollation("ucs2", "ucs2_unicode_520_ci");
        doTestCollation("ucs2", "ucs2_unicode_ci");
        doTestCollation("ucs2", "ucs2_vietnamese_ci");
        doTestCollation("ujis", "ujis_bin");
        doTestCollation("ujis", "ujis_japanese_ci");
        doTestCollation("utf16le", "utf16le_bin");
        doTestCollation("utf16le", "utf16le_general_ci");
        doTestCollation("utf16", "utf16_bin");
        doTestCollation("utf16", "utf16_croatian_ci");
        doTestCollation("utf16", "utf16_czech_ci");
        doTestCollation("utf16", "utf16_danish_ci");
        doTestCollation("utf16", "utf16_esperanto_ci");
        doTestCollation("utf16", "utf16_estonian_ci");
        doTestCollation("utf16", "utf16_general_ci");
        doTestCollation("utf16", "utf16_german2_ci");
        doTestCollation("utf16", "utf16_hungarian_ci");
        doTestCollation("utf16", "utf16_icelandic_ci");
        doTestCollation("utf16", "utf16_latvian_ci");
        doTestCollation("utf16", "utf16_lithuanian_ci");
        doTestCollation("utf16", "utf16_persian_ci");
        doTestCollation("utf16", "utf16_polish_ci");
        doTestCollation("utf16", "utf16_romanian_ci");
        doTestCollation("utf16", "utf16_roman_ci");
        doTestCollation("utf16", "utf16_sinhala_ci");
        doTestCollation("utf16", "utf16_slovak_ci");
        doTestCollation("utf16", "utf16_slovenian_ci");
        doTestCollation("utf16", "utf16_spanish2_ci");
        doTestCollation("utf16", "utf16_spanish_ci");
        doTestCollation("utf16", "utf16_swedish_ci");
        doTestCollation("utf16", "utf16_turkish_ci");
        doTestCollation("utf16", "utf16_unicode_520_ci");
        doTestCollation("utf16", "utf16_unicode_ci");
        doTestCollation("utf16", "utf16_vietnamese_ci");
        doTestCollation("utf32", "utf32_bin");
        doTestCollation("utf32", "utf32_croatian_ci");
        doTestCollation("utf32", "utf32_czech_ci");
        doTestCollation("utf32", "utf32_danish_ci");
        doTestCollation("utf32", "utf32_esperanto_ci");
        doTestCollation("utf32", "utf32_estonian_ci");
        doTestCollation("utf32", "utf32_general_ci");
        doTestCollation("utf32", "utf32_german2_ci");
        doTestCollation("utf32", "utf32_hungarian_ci");
        doTestCollation("utf32", "utf32_icelandic_ci");
        doTestCollation("utf32", "utf32_latvian_ci");
        doTestCollation("utf32", "utf32_lithuanian_ci");
        doTestCollation("utf32", "utf32_persian_ci");
        doTestCollation("utf32", "utf32_polish_ci");
        doTestCollation("utf32", "utf32_romanian_ci");
        doTestCollation("utf32", "utf32_roman_ci");
        doTestCollation("utf32", "utf32_sinhala_ci");
        doTestCollation("utf32", "utf32_slovak_ci");
        doTestCollation("utf32", "utf32_slovenian_ci");
        doTestCollation("utf32", "utf32_spanish2_ci");
        doTestCollation("utf32", "utf32_spanish_ci");
        doTestCollation("utf32", "utf32_swedish_ci");
        doTestCollation("utf32", "utf32_turkish_ci");
        doTestCollation("utf32", "utf32_unicode_520_ci");
        doTestCollation("utf32", "utf32_unicode_ci");
        doTestCollation("utf32", "utf32_vietnamese_ci");

        doTestCollation("utf8mb3", "utf8_bin");
        doTestCollation("utf8mb3", "utf8_croatian_ci");
        doTestCollation("utf8mb3", "utf8_czech_ci");
        doTestCollation("utf8mb3", "utf8_danish_ci");
        doTestCollation("utf8mb3", "utf8_esperanto_ci");
        doTestCollation("utf8mb3", "utf8_estonian_ci");
        doTestCollation("utf8mb3", "utf8_general_ci");
        doTestCollation("utf8mb3", "utf8_general_mysql500_ci");
        doTestCollation("utf8mb3", "utf8_german2_ci");
        doTestCollation("utf8mb3", "utf8_hungarian_ci");
        doTestCollation("utf8mb3", "utf8_icelandic_ci");
        doTestCollation("utf8mb3", "utf8_latvian_ci");
        doTestCollation("utf8mb3", "utf8_lithuanian_ci");
        doTestCollation("utf8mb3", "utf8_persian_ci");
        doTestCollation("utf8mb3", "utf8_polish_ci");
        doTestCollation("utf8mb3", "utf8_romanian_ci");
        doTestCollation("utf8mb3", "utf8_roman_ci");
        doTestCollation("utf8mb3", "utf8_sinhala_ci");
        doTestCollation("utf8mb3", "utf8_slovak_ci");
        doTestCollation("utf8mb3", "utf8_slovenian_ci");
        doTestCollation("utf8mb3", "utf8_spanish2_ci");
        doTestCollation("utf8mb3", "utf8_spanish_ci");
        doTestCollation("utf8mb3", "utf8_swedish_ci");
        // doTestCollation("utf8mb3", "utf8_tolower_ci");
        doTestCollation("utf8mb3", "utf8_turkish_ci");
        doTestCollation("utf8mb3", "utf8_unicode_520_ci");
        doTestCollation("utf8mb3", "utf8_unicode_ci");
        doTestCollation("utf8mb3", "utf8_vietnamese_ci");

        doTestCollation("utf8mb4", "utf8mb4_0900_ai_ci");
        doTestCollation("utf8mb4", "utf8mb4_0900_as_ci");
        doTestCollation("utf8mb4", "utf8mb4_0900_as_cs");

    }

    private static void doTestCollation(String charsetName, String collationName) {
        RelDataType relDataType = FACTORY.createSqlType(SqlTypeName.VARCHAR);

        RelDataType resultType = DataTypeUtil.getCharacterTypeWithCharsetAndCollation(relDataType, charsetName,
            collationName);

        String actual = resultType.getCollation().getCollationName();
        String expect = collationName.toUpperCase();
        Assert.assertEquals(expect, actual);
    }

}
